import WXP from './request'
/*
登录
@param 
code  是	String	code 信息
@return  
openId	String	openId
sessionkey	String	获取用户手机需要的信息
token	String	无——》跳转 注册
*/

// 扫码请求
export function sopScan (data){
  return WXP.request({
    method: 'POST',
    url: '/sop/scan',
    data: {...data}	
  })
}
// 包装线，组件生产线扫码请求
export function userScan (data){
  return WXP.request({
    method: 'POST',
    url: '/sop/userScan',
    data: {...data}	
  })
}

// 获取线体类型
export function findsectionNo (data){
  return WXP.request({
    method: 'POST',
    url: '/sop/findsectionNo',
    data: {...data}	
  })
}
// 获取栈板条码、器件条码数量
export function findDeviceCodeCount (data){
  return WXP.request({
    method: 'POST',
    url: '/device/pts/findDeviceCodeCount',
    data: {...data}	
  })
}
// 获取机台号
export function getMachineList (data){
  return WXP.request({
    method: 'POST',
    url: '/sop/findMachineList',
    data: {...data}	
  })
}

// 扫码请求
export function process (data){
  return WXP.request({
    method: 'POST',
    url: '/sop/process',
    data: {...data}	
  })
}

// EMS总装车间，start
//EMS总装车间扫码
export function emsScan (data){
  return WXP.request({
    method: 'POST',
    url: '/sop/emsScan',
    data: {...data}	
  })
}
//EMS总装车间栈板和机柜条码比对接口
export function packagingComparison (data){
  return WXP.request({
    method: 'POST',
    url: '/device/pts/packagingComparison',
    data: {...data}	
  })
}
//EMS总装车间获取器件、附件规格
export function findProcessJobClassCodeEms (data){
  return WXP.request({
    method: 'POST',
    url: '/sop/findProcessJobClassCodeEms',
    data: {...data}	
  })
}
//EMS总装车间获取条码,pts给
export function ptsCode (data){
  return WXP.request({
    method: 'POST',
    url: '/device/pts/ptsCode',
    data: {...data}	
  })
}
//EMS总装车间获取条码，mes给
export function ptsCodes (data){
  return WXP.request({
    method: 'POST',
    url: '/device/pts/ptsCodes',
    data: {...data}	
  })
}
//查询创建的临技
export function findLinJi (data){
  return WXP.request({
    method: 'POST',
    url: '/device/findLinJi',
    data: {...data}	
  })
}
//数控车间查询绑定机台员工姓名
export function findUser (data){
  return WXP.request({
    method: 'POST',
    url: '/device/findUser',
    data: {...data}	
  })
}
//指定的工序需要临技绑定
export function saveLinJibinding (data){
  return WXP.request({
    method: 'POST',
    url: '/device/saveLinJibinding',
    data: {...data}	
  })
}
//查询需不需要采集emsFacilityBarcode工装设备条码
export function getEmsFacilityBarcode(data){
  return WXP.request({
    method: 'POST',
    // url: '/ems-facility-technology-no-process-order/sel',
    url: '/device/ems-facility-technology-no-process-order/sel',
    data: {...data}	
  })
}

// EMS总装车间，end

// 上传错误
export function addAbnormalInfo(data){
  return WXP.request({
    method: 'POST',
    url: '/sop/addAbnormalInfo',
    data: {...data}	
  })
}

// 获取pdf与视频的url地址
export function getPdfAndVideo(data){
  return WXP.request({
    method: 'POST',
    url: '/sop/getTechnologyFile',
    data: {...data}	
  })
}

// shop指导文件观看记录
export function setUserSopFile(data){
  return WXP.request({
    method: 'POST',
    url: '/sop/setUserSopFile',
    data: {...data}	
  })
}

// sop指导视频观看记录
export function setUserDVideoFile(data){
  return WXP.request({
    method: 'POST',
    url: '/sop/setUserDVideoFile',
    data: {...data}	
  })
}

// 工段长上传SOPID
export function managerLogin(data){
  return WXP.request({
    method: 'POST',
    url: '/sop/managerLogin',
    data: {...data}	
  })
}

// 数控车间部分

// 数控车间扫码请求
export function machineScan (data){
  return WXP.request({
    method: 'POST',
    url: '/sop/machineScan',
    data: {...data}	
  })
}
// 数控车间流转条码获取工单绑定人数
export function findPlanMachine (data){
  return WXP.request({
    method: 'POST',
    url: '/device/findPlanMachine',
    data: {...data}	
  })
}

// 数控车间机台解绑
export function machineUnbindList (data){
  return WXP.request({
    method: 'POST',
    url: '/sop/machineUnbindList',
    data: {...data}	
  })
}

// 数控车间机台绑定
export function machineUnbindList1 (data){
  return WXP.request({
    method: 'POST',
    url: '/sop/machineUnbindList',
    data: {...data}	
  })
}

// 数控车间机台绑定
export function machineBindList (data){
  return WXP.request({
    method: 'POST',
    url: '/sop/machineBindList',
    data: {...data}	
  })
}

// 数控车间异常上传
export function machineAbnormalCommit(data){
  return WXP.request({
    method: 'POST',
    url: '/sop/machineAbnormalCommit',
    data: {...data}	
  })
}

// 数控车间获取绑定该机台的所有工号
export function getBindingUser(data){
  return WXP.request({
    method: 'POST',
    url: '/sop/getBindingUser',
    data: {...data}	
  })
}

//喷涂部分
// 喷涂车间扫码请求
export function machineStationScan (data){
  return WXP.request({
    method: 'POST',
    url: '/sop/sprayScan',
    data: {...data}	
  })
}
// 喷涂自动化接口
export function pt_oneNet(data){
  return WXP.request({
    method: 'POST',
    url: '/sop/pt_oneNet',
    data: {...data}	
  })
}
// 获取机台绑定的员工工号
export function getStationBindingUser(data){
  return WXP.request({
    method: 'POST',
    url: '/sop/getStationBindingUser',
    data: {...data}	
  })
}
// 异常上传
export function machineStationAbnormalCommit(data){
  return WXP.request({
    method: 'POST',
    url: '/sop/machineStationAbnormalCommit',
    data: {...data}	
  })
}

// 校验条码长度
export function selMaterialCodeLen(data){
  return WXP.request({
    method: 'POST',
    url: '/sop/selMaterialCodeLen',
    data: {...data}	
  })
}

//  获取员工工号
export function getBindingStationUser(data){
  return WXP.request({
    method: 'POST',
    url: '/sop/getBindingStationUser',
    data: {...data}	
  })
}

//  获取是否阅读文档阅读
export function getUserTechnologyFileRecord(data){
  return WXP.request({
    method: 'POST',
    url: '/device/getUserTechnologyFileRecord',
    data: {...data}	
  })
}

//喷涂部分

const formatTime = date => {
  const year = date.getFullYear()
  const month = date.getMonth() + 1
  const day = date.getDate()
  const hour = date.getHours()
  const minute = date.getMinutes()
  const second = date.getSeconds()

  return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
}

const formatNumber = n => {
  n = n.toString()
  return n[1] ? n : '0' + n
}
